<template>
	<view class="index-content">
		<view class="topmain">
			<view class="topmain_top">
				<view class="disflex">
					<view class="mab fot21">¥ {{datas.balance || 0}}</view>
					<view>当前余额</view>
				</view>
				<view class="txbtn" @click="withdrawal_btn">提现</view>
			</view>
			<view class="topmain_bot">
				<view class="disflex">
					<view class="mab">¥{{datas.totalIncome||0}}</view>
					<view>累计收益</view>
				</view>
				<view class="disflex">
					<view class="mab">¥ {{datas.stayAmount||0}}</view>
					<view>待分账</view>
				</view>
				<view class="disflex">
					<view class="mab">¥ {{datas.totalWithdrawal||0}}</view>
					<view>提现金额</view>
				</view>
			</view>
		</view>
		<view class="botmain">
			<view class="name">吧台资讯</view>
			<view>
				<img class="imgs" src="../../static/img/banner1.png" alt="">
				<img class="imgs" src="../../static/img/banner2.png" alt="">
				<img class="imgs" src="../../static/img/banner3.png" alt="">
			</view>
			<!-- <uni-load-more :status="loadMoreStatus()" /> -->
		</view>
	</view>
</template>

<script>
	import { barCounterInfo, Information } from '@/api/user.js'
	export default {
		data() {
			return {
				datas:{},
				queryParams: {
					pageNum: 1,
					pageSize: 10,
				},
				list: []
			}
		},
		onLoad() {
			this.getPage()
		},
		onShow() {
			this.page()
		},
		
		// 下拉刷新
		onPullDownRefresh() {
			this.getPage()
		},
		// 上拉加载更多
		onReachBottom() {
			if (this.status == 'noMore') {
				return;
			}
			this.loadMore();
		},
		methods: {
			page() {
				barCounterInfo().then(res => {
					console.log(res)
					localStorage.setItem('InvestorId',res.data.barCounterInvestorId)
					this.datas = res.data
				})
			},
			loadMoreStatus() {
				if (this.loading) return 'loading';
				if (this.finished) return 'more';
				return 'noMore';
			},
			// 加载更多
			loadMore() {
				if (this.loading || this.finished) return;
				this.queryParams.pageNum += 1;
				this.getPage()
			},
			getPage() {
				this.loading = true;
				Information(this.queryParams).then(res => {
					console.log(res, '=================>res')
					if (res.code == '00000') {
						setTimeout(()=> {
							if (this.queryParams.page === 1) {
								this.list = res.data.list;
							} else {
								this.list = this.list.concat(res.data.list)
							}
							if (res.data.list && res.data.list.length < this.queryParams.pageSize) {
								this.status = 'noMore'; // 没有更多数据
							} else {
								this.status = 'more'; // 还有更多数据
							}
						},1000)
					}
					this.loading = false;
					setTimeout(uni.stopPullDownRefresh, 500);
				})
			},
			withdrawal_btn() {
				uni.navigateTo({
					url: '/pages/withdrawal/index'
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.index-content {
		background-color: #f3f4f6;
		min-height: 100vh;
	}

	.topmain {
		padding: 40rpx;
		margin: 20rpx;
		height: 250rpx;
		border-radius: 20rpx;
		background-color: #ceb78f;
		display: flex;
		flex-direction: column;
		justify-content: space-between;

		.disflex {
			font-weight: 600;
			color: #ffffff;

			.mab {
				margin-bottom: 20rpx;
			}
		}

		.topmain_top {
			display: flex;
			justify-content: space-between;
			align-items: center;
			.fot21 {
				font-size: 42rpx;
			}

			.txbtn {
				padding: 12rpx 50rpx;
				background-color: #ffffff;
				color: #c68c21;
				border-radius: 50rpx;
			}
		}
		.topmain_bot {
			display: flex;
			justify-content: space-between;
		}
	}

	.botmain {
		padding: 20rpx;
		margin: 20rpx;
		background-color: #ffffff;
		border-radius: 20rpx;

		.name {
			color: #686c75;
			margin-bottom: 10rpx;
		}

		.imgs {
			width: 100%;
			height: 400rpx;
			border-radius: 20rpx;
			margin-bottom: 10rpx;
		}
	}
</style>